<?php
$dbh = new PDO('mysql:dbname=testbookstore;host=localhost', 'root', 'root');
$stmt = $dbh->prepare("select contenttype, imagedata from images where id=?");
$stmt->execute(array($_GET['id']));
list($type, $lob) = $stmt->fetch();
header("Content-Type: $type");
fpassthru($lob);
?>

